/*
 * Matrix.h
 *
 *  Created on: 02/06/2011
 *      Author: Idan
 */

#ifndef MATRIX_H_
#define MATRIX_H_
#include "mtm.h"
class Matrix {
		int rowsNumber;
		int columnsNumber;
		double** matrixDouble;
//check if current and given matrix has the right dimensions for multiply.
		bool isMatrixSameMultiplayDimensions(const Matrix& matrix) const;
//check if current and given matrix has the same dimensions
		bool isMatrixSameDimensions(const Matrix& matrix) const;
//check if the given number is in the current rows index
		bool isRowInIndex(int row) const;
//check if the given number is in the current columns index
		bool isColumnInIndex(int column) const;
//check if the given numbers is in the current columns and rows index
		bool isInIndex(int row, int column) const;
//check if the given numbers are negative.
		static bool isRowOrColumnNegative(int row,int column);
//check if rows equal columns in the current matrix.
		bool isRowsEqualColumns() const;
//transpose the cell (i,j). meaning swap (i,j) (j,i) cells.
		void transposeCells(int i,int j);
//	Subtract a row multiply by given scalar.
		void substractRow(int row1,int row2, double scalar);
//swap rows
		void swapRows(int row1,int row2);
//multiply a row by given scalar
		void multiplayRowByScalar(int row,double scalar);
//check if matrix is square.
		bool isMatrixSqure() const;
//copy a given matrix data into the current data.
		void copyMatrixData(const Matrix& matrix);
//delete the matrix data.
		void deleteDoubleData();
//making the start point of a column 1, for inverse matters.
		void arrangeStartPointGivenColumn(int columnNumber,
				Matrix& matrixToInverse);
//making the current matrix a unit, doing the same actions on given matrix.
		void toUnit(Matrix& matrixToInverse);
public:
//		c'tors
//		creates a matrix of given sizes
		Matrix(int rowSize, int colSize);
//		copy c'tor.
		Matrix(const Matrix& matrix);
//		return a unit matrix of given size.
		static Matrix createUnit(int matrixSize);
//		= operator. assignment operator.
		Matrix& operator=(const Matrix& matrix);
//		() operator. return a reference of the data in (row,column) cell.
		double& operator()(int row, int column);
//		() operator. return the data in (row,column) cell. x = a(i,j)
		const double& operator()(int row, int column) const;
//		return number of rows.
		int rows() const;
//		return number of columns.
		int columns() const;
//		*= operator for scalar.
		Matrix& operator*=(double scalar);
//		* operator for scalar.
		Matrix operator*(double scalar) const;
//		*= operator for matrix.
		Matrix& operator*=(const Matrix& matrix);
//		+= operator for matrix.
		Matrix& operator+=(const Matrix& matrix);
//		-= operator for matrix.
		Matrix& operator-=(const Matrix& matrix);
//		- operator.
		Matrix operator-() const;
//		!= operator. check if two matrix arn't equal.
		bool operator!=(const Matrix& matrix) const;
//		!= operator. check if two matrix are equal.
		bool operator==(const Matrix& matrix) const;
//		return a transposed copy of given matrix.
		Matrix transpose() const;
//		return an inverse copy of given matrix.
		Matrix inverse() const;
//		destructor
		virtual ~Matrix();
};
//adds two matrix operator.
Matrix operator+(const Matrix& matrixA,const Matrix& matrixB);
//subtract two matrix operator.
Matrix operator-(const Matrix& matrixA,const Matrix& matrixB);
//multiply two matrix operator.
Matrix  operator*(const Matrix& matrixA,const Matrix& matrixB);



#endif /* MATRIX_H_ */
